//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>

#include "PsiPredProt.h"
#include "ProcessCathFASTAProfile.h"
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
using namespace std;
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
int main (int argc, char** argv) {
  
  String* namefileFASTAProfileIn  = NULL;
  String* namefileFASTAProfileOut = NULL;
  String* psiPredPath             = NULL;

  if (argc < 4) {
    
    ///usr/local/psipred/runpsipred
    cout << "Error in the input parameters! Must by like: " << endl;
    cout << "./PredictSecondaryStructure <Path to PSIPRED executable Script> <Profile FASTA File In> <Profile FASTA File Out>" << endl;
    
    return 0;
    
  }
  else {
    
    psiPredPath             = new String(argv[1]);
    namefileFASTAProfileIn  = new String(argv[2]);
    namefileFASTAProfileOut = new String(argv[3]);
    
    cout << "---------------------------------------------------------------------------------" << endl;
    cout << " PSIPRED Executable script : " << argv[1] << endl;
    cout << "     Profile FASTA File In : " << argv[2] << endl;
    cout << "    Profile FASTA File Out : " << argv[3] << endl;
    cout << "---------------------------------------------------------------------------------" << endl;
    
  }
  
  ProcessCathFASTAProfile* processCathFASTAProfile = new ProcessCathFASTAProfile ();
  
  cout << "Preparing Files..." << endl;
  processCathFASTAProfile->NamefileIn(namefileFASTAProfileIn);
  processCathFASTAProfile->NamefileOut(namefileFASTAProfileOut);
  
  cout << "Loading Profile FASTA File with Domain Descriptions..." << endl;
  processCathFASTAProfile->LoadData();
  
  cout << "Number of Domains: " << processCathFASTAProfile->ListCathDomainProfile()->Length() << endl;
  
  cout << "Computing the Secondary Structure of each Domain and Updating the Out File..." << endl;
  processCathFASTAProfile->UpdatePredictSecondaryStructure(psiPredPath);
  
  cout << "Finished..." << endl << "Good Bye" << endl;
  
  if (processCathFASTAProfile) delete processCathFASTAProfile;
  
  if (psiPredPath)             delete psiPredPath;
  if (namefileFASTAProfileIn)  delete namefileFASTAProfileIn;
  if (namefileFASTAProfileOut) delete namefileFASTAProfileOut;

  return EXIT_SUCCESS;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//

